<?php
namespace App\Repositories\Personal;

use Illuminate\Http\Request;


class PersonalFilter
{
    protected $perPage;
    protected $sort;
    protected $startTime;
    protected $endTime;

    public function __construct(Request $request)
    {
        $this->startTime = $request->get('start_time');
        $this->endTime = $request->get('end_time');
        $this->perPage = max(min((int)$request->get('per_page', 20), 100), 1);
        $this->sort = parseSortString($request->get('sort'));
    }

    /**
     * @return mixed
     */
    public function getStartTime()
    {
        return $this->startTime;
    }

    /**
     * @return mixed
     */
    public function getEndTime()
    {
        return $this->endTime;
    }

    /**
     * @return mixed
     */
    public function getPerPage()
    {
        return $this->perPage;
    }

    /**
     * @return array
     */
    public function getSort(): array
    {
        return $this->sort;
    }
}
